package fileby.util;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author Ludwig Kjellstrom
 */
public class FileUtil {


    public static FileFilter getClassFileFilter() {
        return new FileFilter() {

            @Override
            public String getDescription() {
                return "Compiled .class-files only.";
            }

            @Override
            public boolean accept(File f) {
                if (f == null)
                    return false;
                if (f.isDirectory())
                    return true;
                String ext = "";
                String s = f.getName();
                int i = s.lastIndexOf('.');
                if (i > 0 && i < s.length() - 1)
                    ext = s.substring(i + 1).toLowerCase();
                return ext.equalsIgnoreCase("class");
            }
        };
    }

}